const { src, dest } = require('gulp');
const { join } = require('path');
const postcss = require('gulp-postcss');
const tailwindcss = require('tailwindcss');
const nested = require('postcss-nested');
const cssnano = require('cssnano');
const autoprefixer = require('autoprefixer');
const rename = require('gulp-rename');
const { paths } = require('./utils');

function css() {
  return src(join(paths.dev.css, '**/*.css'))
    .pipe(postcss([tailwindcss, nested, autoprefixer, cssnano]))
    .pipe(
      rename((p) => {
        p.basename += '.min';
        p.extname = '.css';
      })
    )
    .pipe(dest(paths.prod.css));
}

exports.css = css;
